<template>
  <div class="jingtiao">
    <div class="content_title">
      <span class="content_text">并条</span>
      <img
        class="content_img"
        src="@/assets/img/chart/jingtiao.png"
        alt=""
        srcset=""
      />
    </div>
    <div class="jingtiao_body">
      <div class="jingtiaoCol">
        <div
          v-for="(item, index) in jingtiaoData.jingtiaoCol1Data"
          :key="index + 's'"
          class="jingtiao_item"
        >
          <div v-if="index == 0">
            <div class="dongli" @click="clickHandleDl('jingtiao_' + index)">
              <img src="@/assets/img/dongligui.png" alt="" srcset="" />
            </div>
          </div>
          <div @click="clickHandle('jingtiao', item)">
            <jingtiaol :data="item"></jingtiaol>
          </div>
        </div>
      </div>
      <div class="jingtiaoCol">
        <div
          v-for="(item, index) in jingtiaoData.jingtiaoCol2Data"
          :key="index + 'f'"
          class="jingtiao_item"
          @click="clickHandle('jingtiao', item)"
        >
          <jingtiaor :data="item"></jingtiaor>
        </div>
      </div>
    </div>
    <!-- 并条弹窗控件 -->
    <jingtiaoDialog ref="jingtiaoDialog" />
    <!-- 粗纱弹窗控件 -->
    <cushaDialog ref="cushaDialog2" />
    <!-- 动力柜弹窗控件 -->
    <dongliDialog ref="dongliDialog"></dongliDialog>
  </div>
</template>

<script>
import dongliDialog from '../qcs/dialog/dialog_dongli/index';
import jingtiaoDialog from '../qcs/dialog/dialog_jingtiao/index';
import cushaDialog from '../qcs/dialog/dialog_cusha/index';
import jingtiaol from '../qcs/jingtiao_l';
import jingtiaor from '../qcs/jingtiao_r';
import cusha from '../qcs/cusha';
import COMMON from '@/utils/common';
import dongLiMenu from '../data/dongli.json';
import dongliItem from '../data/dongliItem.json';
export default {
  name: 'JingTiao',
  props: {
    msg: String
  },
  components: {
    dongliDialog,
    jingtiaol,
    jingtiaor,
    jingtiaoDialog,
    cushaDialog,
    cusha
  },
  data() {
    return {
      jingtiaoData: {
        // 1-12
        jingtiaoCol1Data: [],
        // 1-12
        jingtiaoCol2Data: []
      },
      cushaData: {
        // 15-16
        cushaDataRow2Data: []
      },
      dongLiMenu: {},
      dongLiItem: {}
    };
  },
  created() {
    this.dongLiMenu = dongLiMenu;
    this.dongLiItem = dongliItem;
  },
  methods: {
    closeHandle() {
      this.$parent.$parent.$parent.closeParentHandle();
    },
    clickHandle(flag, item) {
      switch (flag) {
        case 'cusha':
          this.$parent.$parent.$parent.getInfoByDevSn('TXCSOML', item.devSn);
          this.$refs.cushaDialog2.showDialog(item);
          break;
        case 'jingtiao':
          this.$parent.$parent.$parent.getInfoByDevSn('BINGTIAO', item.devSn);
          this.$refs.jingtiaoDialog.showDialog(item);
          break;
      }
    },
    clickHandleDl(item) {
      var getInfoQuary = this.dongLiMenu[item];
      var dialogData = this.dongLiItem[item];
      this.$parent.$parent.$parent.getInfoByDevSn('DONGLI', getInfoQuary);
      this.$refs.dongliDialog.showDialog(dialogData);
    }
  },
  computed: {
    bingTiaoGroupState() {
      return this.$store.state.workshop.bingTiaoGroupState;
    },
    txcsomlGroupState() {
      return this.$store.state.workshop.txcsomlGroupState;
    }
  },
  watch: {
    bingTiaoGroupState: {
      immediate: true,
      handler(val) {
        this.jingtiaoData.jingtiaoCol1Data = COMMON.devSnFilter(
          val.data,
          1,
          99
        );
        this.jingtiaoData.jingtiaoCol2Data = COMMON.devSnFilter(
          val.data,
          99,
          200
        );
        if (this.jingtiaoData.jingtiaoCol1Data.length > 0) {
          var data1_f = {
            devSn: '1',
            stateCode: '5',
            time: '2021-09-1',
            xiaolv: '0.15'
          };
          var data1_h = {
            devSn: '101',
            stateCode: '5',
            time: '2021-09-1',
            xiaolv: '0.15'
          };
          this.jingtiaoData.jingtiaoCol1Data.splice(0, 0, data1_f);
          this.jingtiaoData.jingtiaoCol2Data.splice(0, 0, data1_h);
        }
      }
    },
    txcsomlGroupState: {
      immediate: true,
      handler(val) {
        this.cushaData.cushaDataRow2Data = COMMON.devSnFilter(val.data, 15, 16);
      }
    }
  }
};
</script>

<style scoped></style>
